import wx


# 画点
class MyFrame(wx.Frame):
    def __init__(self, parent, title):
        super().__init__(parent, title=title, size=(300, 200))
        self.panel = wx.Panel(self)
        self.label = wx.StaticText(self.panel, label="Hello, wxPython!", pos=(50, 50))
        self.button = wx.Button(self.panel, label="点击我", pos=(50, 100))
        self.button.Bind(wx.EVT_BUTTON, self.on_button_click)

        # 创建一个画布
        self.canvas = wx.Panel(self.panel)
        self.canvas.SetBackgroundColour(wx.RED)
        self.canvas.SetSize((20, 20))
        self.canvas.SetPosition((10, 10))
        # 绑定画布的绘制事件
        self.canvas.Bind(wx.EVT_PAINT, self.on_paint)

    def on_paint(self, event):
        dc = wx.PaintDC(self.canvas)
        dc.DrawPoint(100, 100)


    # 绑定按钮事件
    def on_button_click(self, event):
        self.label.SetLabel("按钮被点击了")

if __name__ == '__main__':
    app = wx.App()
    frame = MyFrame(None, title="Hello, wxPython!")
    frame.Show()
    app.MainLoop()
